#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from db import get_conn

def check_specific_customer():
    """检查特定客户的数据"""
    print("🔍 检查客户'段克文'的数据...")
    
    try:
        conn = get_conn()
        cursor = conn.cursor()
        
        # 查询特定客户
        cursor.execute("SELECT * FROM userinfo WHERE PID = '110000000000000017'")
        customer = cursor.fetchone()
        
        if customer:
            print(f"✅ 找到客户:")
            print(f"   客户编号: {customer['customerID']}")
            print(f"   客户姓名: '{customer['customerName']}' (类型: {type(customer['customerName'])})")
            print(f"   身份证号: {customer['PID']}")
            print(f"   联系电话: {customer['telephone']}")
            print(f"   联系地址: {customer['address']}")
            
            # 检查客户姓名是否为空
            if not customer['customerName'] or customer['customerName'].strip() == '':
                print("❌ 问题: 客户姓名为空!")
                # 更新客户姓名
                cursor.execute("UPDATE userinfo SET customerName = '段克文' WHERE PID = '110000000000000017'")
                conn.commit()
                print("✅ 已修复客户姓名")
            else:
                print("✅ 客户姓名正常")
        else:
            print("❌ 未找到该客户")
        
        cursor.close()
        conn.close()
        
    except Exception as e:
        print(f"❌ 查询失败: {e}")

if __name__ == "__main__":
    check_specific_customer() 